#include <iostream>
#include <algorithm>
#include <list>
 
using namespace std;

template <typename TypeA>
void display(const list<TypeA> &lis, ostream &os)
{
    typename list<TypeA>::const_iterator iter = lis.begin();
    typename list<TypeA>::const_iterator end_it = lis.end();

    for (; iter != end_it; iter++)
    {
        os << *iter << ' ';
    }
    os << endl;
}

int main()
{
//    vector<int> vec_int = {1, 5, 6, 75, 24};
//    vector<string> vec_string = {"sfv", "sdsd", "dscs", "rgvd", "fdvw"};
    list<int> lis = {454, 542, 545, 68, 85};

    lis.sort();
    display(lis, cout);

    list<int>::iterator it = lis.begin();
    int num = 512;
    while (it != lis.end())
    {
        if (*it >= num)
        {
            lis.insert(it, num);
            break;
        }
        ++it;
    }

    display(lis, cout);
}